export default ({ app: { $request } }, inject) => {
  inject('api', {
    loginAuth(data) {
      return $request.post('/v1/auth/login', data)
    },
    isAuth() {
      return $request.get('/v1/auth/authentication')
    },

    getUserNotificationNum() {
      return $request.get('v1/users/userNotificationNum');
    },
    setUserNotificationNum() {
      return $request.put('v1/users/userNotificationNum');
    },

    // 获取首页列表
    getIndexList(data = {}) {
      return $request.post('/v1/articles/indexList', data)
    },
    // 获取推荐坐着
    getRecommendAuthor(params = {}) {
      return $request.get('/v1/recommends/recommendAuthor', params)
    },
    // 推荐小册
    getRecommendBook() {
      return $request.get('/v1/recommends/books')
    },

    /**
     * 获取类目
     */
    getCategories() {
      return $request.get('/v1/categories/entry')
    },
    articleLike(data = {}) {
      let method = data.isCollected ? 'put' : 'delete'
      return $request[method]('/v1/users/like', { entryId: data.entryId })
    },
    // 获取用户消息
    getUserNotification(params = {}) {
      return $request.get('/v1/users/notification', params);
    },
    //  获取沸点 推荐 热门 关注
    getPinList(params = {}) {
      return $request.get('/v1/pins/list', params)
    },
    followUser(data = {}) {
      return $request[data.method]('/v1/users/follow', {
        follower: data.follower,
        followee: data.followee
      })
    },
    followTag(data = {}) {
      return $request[data.method]('/v1/tags/subscribe', {
        tagId: data.tagId
      })
    },
    //  获取用户信息
    getMultiUser(params = {}) {
      return $request.get('/v1/users/multiUser', params)
    },
    getUserPost(params = {}) {
      return $request.get('/v1/articles/userPost', params);
    },
    /**
     * 检查是否关注用户
     * @param {staring} currentUid
     * @param {string} targetUids
     */
    isCurrentUserFollowed(params = {}) {
      return $request.get('/v1/users/isCurrentUserFollowed', params)
    },

    getDetail(params = {}) {
      return $request.get('/v1/articles/detail', params)
    },
    getRelatedEntry(params = {}) {
      return $request.get('/v1/articles/relatedEntry', params)
    },

    getRecommendEntryByTagIds(params = {}) {
      return $request.get('/v1/articles/recommendEntryByTagIds', params)
    },

    getReplyList(params = {}) {
      return $request.get('/v1/comments/reply', params)
    },
    getCommentList(params = {}) {
      return $request.get('/v1/comments/entry', params)
    },
    isArticleLike(params = {}) {
      return $request.get('/v1/users/isArticleLike', params)
    },
    getPinCommentList(params = {}) {
      return $request.get("/v1/comments/pinComment", params)
    },
    getPinListByRecommend(){
      return $request.get("/v1/pins/hotRecommendList")
    },
    getFollowedTopics(params = {}) {
      return $request.get('/v1/topics/followedList', params)
    },
    getPinListByTopic(params = {}) {
      return $request.get('/v1/pins/topicList', params)
    },
    getPinReplyList(params = {}){
      return $request.get('/v1/comments/pinReply', params)
    },
    getPinById(params = {}) {
      return $request.get('/v1/pins/byId', params)
    },

    getTopicPinList(params = {}) {
      return $request.get('/v1/topics/pinList', params)
    },
    getTopicAttenderList(params = {}) {
      return $request.get('/v1/topics/attenders', params)
    },
    getTopicDetail(params = {}) {
      return $request.get('/v1/topics/detail', params)
    },
    getTopics(params = {}) {
      return $request.get('/v1/topics/list', params)
    },
    followTopic(data = {}){
      return $request[data.method]('/v1/topics/follow', {
        topicIds: data.topicIds
      })
    },
    getBookChannel() {
      return $request.get('/v1/books/channel')
    },
    getBooks(params = {}) {
      return $request.get('/v1/books/getListByLastTime', params)
    },
    getTagDetail(params = {}){
      return $request.get('/v1/tags/detail', params)
    },
    getTagEntry(params = {}){
      return $request.get('/v1/tags/entry', params)
    }
  })
}
